﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="WebApplication1.WebForm1" CodeBehind="WebForm1.aspx.cs" %>

<!DOCTYPE html>

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
		body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
	</style>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=NzHMZsCXljxfF13tN1eBOMUf"></script>
	<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>
	<titlGCJ-02转百度</title>
</head>
<body>
	<div id="allmap">
        <input id="xxx" type="text" runat="server"  />
         <input id="yyy" type="text" runat="server"  />
	</div>
    <p>
        &nbsp;</p>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    //谷歌坐标
    var x = xxx.value;
    var y = yyy.value;

    var ggPoint = new BMap.Point(x, y);

    //地图初始化
    var bm = new BMap.Map("allmap");
    bm.centerAndZoom(ggPoint, 15);
    bm.addControl(new BMap.NavigationControl());

  

    //坐标转换完之后的回调函数
    translateCallback = function (point) {
        var marker = new BMap.Marker(point);
        bm.addOverlay(marker);
        var label = new BMap.Label("我的位置", { offset: new BMap.Size(20, -10) });
        marker.setLabel(label); //添加百度label
        bm.setCenter(point);


        //alert("google坐标转成百度坐标:" + point.lng + "," + point.lat);
    }






    setTimeout(function () {
        BMap.Convertor.translate(ggPoint, 2, translateCallback);     //GCJ-02坐标转成百度坐标
    }, 1000);
</script>

